﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace project1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        double a, b;
        string op;
        private void Form1_Load(object sender, EventArgs e)
        {
           
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                b = double.Parse(textBox2.Text);
            }
            catch
            {
                textBox2.Text = "WrongData";
            }
            try
            {
                a = double.Parse(textBox1.Text);
            }
            catch
            {
                textBox1.Text = "WrongData";
            }
            if (textBox1.Text.Length != 0&&textBox2.Text.Length != 0&& textBox3.Text.Length != 0&&textBox1.Text!= "WrongData"&& textBox2.Text != "WrongData") {
                op = textBox3.Text;
                if (op == "+") textBox4.Text = (a + b).ToString();
                else if (op == "-") textBox4.Text = (a - b).ToString();
                else if (op == "*") textBox4.Text = (a * b).ToString();
                else if (op == "/" && b != 0) textBox4.Text = (a / b).ToString();
                else textBox4.Text = "erro";
            }
            else textBox4.Text = "erro";
        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
           
        }
    }
}
